import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		/**
		 * 是否需要强制登录
		 */
		forcedLogin: false,
		hasLogin: false,
		userName: ""
	},
	mutations: {
		login(state, userName='新用户') {
			state.userName = userName;
			state.hasLogin = true;
			state.forcedLogin=true
		},
		logout(state) {
			state.userName = "";
			state.hasLogin = false;
		}
	},
	actions:{
		login({commit},{userName,password}){
			return new Promise((resolve,reject)=>{
				commit('login','xiejiarong');
				resolve();
				
			}).catch()
		}
	}
})

export default store
